<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" placeholder="请输入成绩" />
    <button>查看</button>
  </body>
</html>
<script>
  var btn = document.querySelector("button");
  var num = document.querySelector("input");
  btn.onclick = function () {
    if (num.value.trim() == "") return alert("请输入内容");
    if (isNaN(num.value)) return alert("请输入数字");
    if (num.value > 100 || num.value < 0) {
      alert("输入成绩无效");
    } else if (num.value >= 90) {
      alert("该学生评分为A");
    } else if (num.value >= 80) {
      alert("该学生评分为B");
    } else if (num.value >= 70) {
      alert("该学生评分为C");
    } else if (num.value >= 60) {
      alert("该学生评分为D");
    } else {
      alert("该学生评分为E");
    }
  };
</script>
